import os

BASE_DIR = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))

class Config:
    UPLOAD_FOLDER = os.path.join(BASE_DIR, 'static/uploads')
    RESULT_FOLDER = os.path.join(BASE_DIR, 'static/results')
    AVATARS_FOLDER = os.path.join(BASE_DIR, 'static/avatars')
    DEVICE_IMG_FOLDER = os.path.join(BASE_DIR, 'static/device_images')
    
    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:330683@localhost/iot_app?charset=utf8mb4'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    
    # 邮件配置
    MAIL_SERVER = 'smtp.exmail.qq.com'
    MAIL_PORT = 465
    MAIL_USE_TLS = False
    MAIL_USE_SSL = True
    MAIL_USERNAME = 'admin@tjh666.cn'
    MAIL_PASSWORD = 'XDYURk9ZNHiHXgCN'
    MAIL_DEFAULT_SENDER = 'admin@tjh666.cn'
    
    # YOLO类别映射
    YOLO_CLASS_MAPPING = {
        'person': '人',
        'bicycle': '自行车',
        'car': '汽车',
        'motorcycle': '摩托车',
        'airplane': '飞机',
        'bus': '公交车',
        'train': '火车',
        'truck': '卡车',
        'boat': '船',
        'traffic light': '交通灯',
        'fire hydrant': '消防栓',
        'stop sign': '停止标志',
        'parking meter': '停车计时器',
        'bench': '长椅',
        'bird': '鸟',
        'cat': '猫',
        'dog': '狗',
        'horse': '马',
        'sheep': '羊',
        'cow': '牛',
        'elephant': '大象',
        'bear': '熊',
        'zebra': '斑马',
        'giraffe': '长颈鹿',
        'backpack': '背包',
        'umbrella': '雨伞',
        'handbag': '手提包',
        'tie': '领带',
        'suitcase': '箱子',
        'frisbee': '飞盘',
        'skis': '滑雪板',
        'snowboard': '滑雪板',
        'sports ball': '运动球',
        'kite': '风筝',
        'baseball bat': '棒球棒',
        'baseball glove': '棒球手套',
        'skateboard': '滑板',
        'surfboard': '冲浪板',
        'tennis racket': '网球拍',
        'bottle': '瓶子',
        'wine glass': '酒杯',
        'cup': '杯子',
        'fork': '叉子',
        'knife': '刀',
        'spoon': '勺子',
        'bowl': '碗',
        'banana': '香蕉',
        'apple': '苹果',
        'sandwich': '三明治',
        'orange': '橙子',
        'broccoli': '西兰花',
        'carrot': '胡萝卜',
        'hot dog': '热狗',
        'pizza': '披萨',
        'donut': '甜甜圈',
        'cake': '蛋糕',
        'chair': '椅子',
        'couch': '沙发',
        'potted plant': '盆栽',
        'bed': '床',
        'dining table': '餐桌',
        'toilet': '马桶',
        'tv': '电视',
        'laptop': '笔记本电脑',
        'mouse': '鼠标',
        'remote': '遥控器',
        'keyboard': '键盘',
        'cell phone': '手机',
        'microwave': '微波炉',
        'oven': '烤箱',
        'toaster': '烤面包机',
        'sink': '水槽',
        'refrigerator': '冰箱',
        'book': '书',
        'clock': '时钟',
        'vase': '花瓶',
        'scissors': '剪刀',
        'teddy bear': '泰迪熊',
        'hair drier': '吹风机',
        'toothbrush': '牙刷'
    }
    
    # 添加设备图片存储文件夹配置
    DEVICE_FOLDER = 'uploads/devices'
    
    @staticmethod
    def init_app(app):
        # 创建必要的目录
        for folder in [app.config['UPLOAD_FOLDER'],
                      app.config['RESULT_FOLDER'],
                      app.config['AVATARS_FOLDER'],
                      app.config['DEVICE_IMG_FOLDER'],
                      app.config['DEVICE_FOLDER']]:
            os.makedirs(folder, exist_ok=True) 